package com.buba.system.controller;

import com.alibaba.fastjson.JSON;
import com.buba.system.pojo.Role;
import com.buba.system.service.RoleService;
import com.buba.system.service.impl.RoleServiceImpl;
import com.buba.util.BaseServlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import java.util.Map;

@WebServlet("/RoleServlet")
public class RoleServlet extends BaseServlet {
    RoleService roleService = new RoleServiceImpl();
    @Override
    public void doRequest(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
        String flag = request.getParameter("flag");
        if ("selRole".equals(flag))
            this.selRole(request,response);
    }

    private void selRole(HttpServletRequest request, HttpServletResponse response) throws IOException {
        Map<String, String> param = getParam(request);
        List<Role> list = roleService.selRole();
        response.getWriter().write(JSON.toJSONString(list));
    }
}
